<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>评估单新增</title>
		<link rel="stylesheet" type="text/css" href="../lib/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="../css/reset.css" />
		<link rel="stylesheet" type="text/css" href="evalution.css" />
	</head>
	<body>
		<div class="layui-form ">
			<div class="title">
				<button type="button" class="layui-btn" lay-submit="" lay-filter="back">返回</button>
				<div class="pgd-con">
					<div class="tit">
						<h2>压疮Braden评估表</h2>
						<ul class="clearfix">
							<li>姓名：nam</li>
							<li>性别：sex</li>
							<li>年龄：age</li>
							<li>科室：科室</li>
							<li>床号：科室</li>
							<li>住院号：科室</li>
						</ul>
						<div>
							<div>
								<label class="layui-form-label">评估时间:</label>
								<div class="layui-input-block">
									<input type="text" name="" placeholder="" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
					</div>

					<div>
						<!-- 模板 -->
						<script id="demo" type="text/html">
							<!-- 1-具体评分 -->
					<div class="jtpf-con">
						<div class="fw700">
							<span>{{ d.data.modules[0].categoryName }}</span>
							<span>({{ d.data.modules[0].tabWords || '' }})</span>
						</div>
							<ul class="th clearfix">
								<li>评分项目</li>
								<li>具体评分可选项</li>
								<li>单项得分</li>
							</ul>
							<ul id="dx">
								{{#  layui.each(d.data.modules[0].items, function(index, module){ }}
									<li>
										<span class="w20p">{{module.questionName}}</span>
										<!-- <span class="w20p">{{module.codeName}}</span> -->
										  {{#  layui.each(module.elements, function(index, element){ }}
											  <input type="radio" name="{{module.codeName}}" id="" value="{{element.itemValue}}" /><label for="">{{element.itemName}}</label>
										  {{#  }); }}
										  {{#  if(module.elements.length === 0){ }}
											无数据
										  {{#  } }} 
									</li>
								{{#  }); }}
								{{#  if(d.data.modules[0].items.length === 0){ }}
								  无数据
								{{#  } }} 
							</ul>
						<p>{{ d.data.modules[0].remainWords }}</p>
					</div>
					<!-- 2-预防措施 -->
					<div class="jtpf-con">
						<div class="fw700">
							<span>{{ d.data.modules[1].categoryName }}</span>
							<span>({{ d.data.modules[1].tabWords || '' }})</span>
						</div>
						{{#  layui.each(d.data.modules[1].items, function(index, module){ }}
							<div class="bgc tit">{{module.questionName}}</div>
						    <div>
								<!-- <span class="w20p">{{module.codeName}}</span> -->
								  {{#  layui.each(module.elements, function(index, element){ }}
									  <span><input type="checkbox" name="{{element.itemName}}" id="" value=""/><label for="">{{element.itemName}}</label></span>
								  {{#  }); }}
								  {{#  if(module.elements.length === 0){ }}
								    无数据
								  {{#  } }} 
							</div>
						{{#  }); }}
						{{#  if(d.data.modules[0].items.length === 0){ }}
						  无数据
						{{#  } }} 
						<!-- <p>{{ d.data.modules[0].remainWords }}</p> -->
					</div>
					</script>
						<!-- 模板容器 -->
						<div id="view"></div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn save" lay-submit="" lay-filter="test">保存</button>

					</div>
				</div>
			</div>
	</body>
	<script src="../js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<!-- <script src="add.js" type="text/javascript" charset="utf-8"></script> -->
	<script type="text/javascript">
		layui.use(['laypage', 'form', 'element', 'laytpl'], function() {
			var laytpl = layui.laytpl;
			var element = layui.element;
			var laypage = layui.laypage;
			var form = layui.form;

			// save提交参数
			var userId = 2723,
				userName = "nina",
				patientId = 100108597,
				evaluationId = 1,
				entityId = 2;

			var param = JSON.stringify({
				"body": {
					"templateId": 2
				},
				"header": {},
				"token": {}
			});
			$.ajax({
				'type': 'post',
				'url': '/service-nursing/evalution/template',
				'data': param,
				'dataType': 'json',
				'contentType': "application/json",
				'success': function(data) {
					console.log(data);
					var getTpl = demo.innerHTML,
						view = document.getElementById('view');
					laytpl(getTpl).render(data, function(html) {
						view.innerHTML = html;
					});

					var d = data.data
					var arr = []
					//监听提交
					$(".save").click(function() {
						// layui.each(d.modules[0].items, function(index, module){
						// 	console.log(module);
						// }
						// layui.each(d.modules[1].items, function(index, module){
						// 	layui.each(module.elements, function(index, element){
						// 		console.log(element);
						// 	}
						// }
					})


				},
				'error': function(res) {
					console.log(res);
				}
			});

			// form.on('submit(test)', function(data) {
			// 	console.log(data);

			// var saveparam = JSON.stringify({
			// 	"body": {
			// 		"userId": 2723,
			// 		"userName": "nina",
			// 		"patientId": 100108597,
			// 		"evaluationId": 1,
			// 		"entityId": 2,
			// 		"records": arr
			// 	},
			// 	"header": {},
			// 	"token": {}
			// });
			// $.ajax({
			// 	'type': 'post',
			// 	'url': '/service-nursing/evalution/saveOrModify',
			// 	'data': saveparam,
			// 	'dataType': 'json',
			// 	'contentType': "application/json",
			// 	'success': function(data) {
			// 		console.log(data);
			// 	},
			// 	'error': function(res) {
			// 		console.log(res);
			// 	}
			// });
			// 	return false;
			// });
		})
	</script>
</html>
